<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>

  <body>
    <script>
      //Promise的静态方法 resolve
      Promise.resolve('foo');
      // 等价于
      new Promise((resolve) => resolve('foo'));

      Promise.resolve(1)
        .then((res) => {
          console.log('成功');
          console.log(res);
        })
        .catch((res) => {
          console.log('失败');
          console.log(res);
        });

      //Promise的静态方法 reject
      Promise.reject(2)
        .then((res) => {
          console.log('成功');
          console.log(res);
        })
        .catch((res) => {
          console.log('失败');
          console.log(res);
        });
    </script>
  </body>
</html>
